<?php
class ControllerSaleTransactionLevel extends Controller {
	private $error = array();

	public function index() {
	$this->language->load('sale/customer');

		$this->document->setTitle('Thanh Toán Hoa Hồng Theo Cấp Thành Viên');

		$this->load->model('sale/customer');
		if(isset($this->request->get['customer_id'])){
			$results = $this->model_sale_customer->getCustomer($this->request->get['customer_id']);
			if($results){
			// hoa hồng trực tiếp
			$customers = $this->model_sale_customer->getCustomersByParent($results['customer_id']);
			
			$this->data['customers'] = array();
		
			// Customer
			if($customers){
				foreach($customers as $customer){
					$this->data['customers'][] = array(
						'name'       => $customer['name'],
						'madn'       => $customer['madn'],
						'level'		 => $customer['level2'],
						'date_added' => date('d/m/Y',strtotime($customer['date_added']))
					);
				}
			}
			$this->data['customers_id'] = $results['customer_id'];
			$this->data['name']         = $results['name'];
			$this->data['madn']         = $results['madn'];
			$this->data['money']        = $this->currency->format($results['price']);
			$this->data['status']       = $results['status'] ? 'Đã chuyển' : 'Chưa chuyển';
			$this->data['date_added']   = date($this->language->get('date_format_short'), strtotime($results['date_added']));
			$this->data['href']   =  $this->url->link('customer/edit');
			$this->template = 'sale/hoahong.tpl';	
			$this->children = array(
				'common/footer',
				'common/header'	
			);
							
			$this->response->setOutput($this->render());	
		}
	}
  }
}
?>